home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 3 / Cream of the Crop 3.iso / clipper / ks94an.zip / TXTARRAY.HDR < prev    next >
Text File  |  1994-04-25  |  2KB  |  64 lines

  1. /******************************************************************************
  2.                  The Klipper Library, for CA-Clipper 5.x
  3.         Copyright (c), 1994, Wallace Information Systems Engineering
  4.  
  5. FUNCTION:
  6.  
  7. _TextArray(cFileName, nWidth) --> acTextArray
  8.  
  9. PARAMETERS:
  10.  
  11. cFileName : Text file to read
  12. nWidth    : Width of array elements (optional)
  13.  
  14. SHORT:
  15.  
  16. Loads the contents of a text file into an array
  17.  
  18. DESCRIPTION:
  19.  
  20. _TextArray() reads the specified text file, adding each line to an
  21. array (which is returned as the function return value).
  22.  
  23. If nWidth is specified, the array is created at that width and any
  24. characters in a line exceeding this length are truncated.
  25.  
  26. If nWidth is NOT specified, then the array is is sized to the width of
  27. the longest line in the text file.  This is slower since one full read of
  28. the text file must be done in order to determine the longest element needed.
  29.  
  30. _TextArray() returns the array with text data or empty() if the file does
  31. not exist or if the file is itself empty.
  32.  
  33. NOTE:
  34.  
  35. See also, _ArrayText() which writes an array to a text file.
  36.  
  37. EXAMPLE:
  38.  
  39. LOCAL acFileData := {}
  40.  
  41. acFileData := _TextArray('DATA.TXT', 80)
  42.  
  43. Result:  DATA.TXT is copied into an array called acFileData.  Any file
  44. data extending past column 80 is truncated.
  45.  
  46. *--------------------------------------------------------------
  47.  
  48. LOCAL acFileData := {}
  49. acFileData := _TextArray('DATA.TXT')
  50.  
  51. Result: DATA.TXT is copied into an array called acFileData.  The array
  52. is horizontally dimensioned (width) to accept the longest line in DATA.TXT
  53. In the default case, the longest line is 1024 chars.
  54.  
  55. *--------------------------------------------------------------
  56.  
  57. LOCAL acFileData := {}
  58. acFileData := _TextArray('NOEXIST.TXT')
  59.  
  60. Result: In this case, it is presumed that NOEXIST.TXT does not exist, in
  61. which case, empty(acFileData) = TRUE.
  62.  
  63. ******************************************************************************/
  64.